<?xml version="1.0" encoding="utf-8" ?>
<sqlMap namespace="TApprover" xmlns="http://ibatis.apache.org/mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<alias>
    <typeAlias alias="TApprover" type="EIA.PM.Model.TApprover, EIA.PM.Model" />
</alias>

<resultMaps>
<resultMap id="select-tapprover-result" class="TApprover">
<constructor>
    <argument argumentName="apv_id" column="apv_id"/>
    <argument argumentName="stf_id" column="stf_id"/>
    <argument argumentName="stf_name" column="stf_name"/>
    <argument argumentName="apv_type" column="apv_type"/>
    <argument argumentName="apv_alias" column="apv_alias"/>
</constructor>
<!--
    <result property="ApvId" column="apv_id"/>
    <result property="StfId" column="stf_id"/>
    <result property="StfName" column="stf_name"/>
    <result property="ApvType" column="apv_type"/>
    <result property="ApvAlias" column="apv_alias"/>
-->
</resultMap>
</resultMaps>

<statements>
<sql id="sql_TApprover_where_pk">
WHERE apv_id=#ApvId#
</sql>

<sql id="sql_TApprover_where_cv">
<dynamic prepend="WHERE">
    <isPropertyAvailable property="ApvId" prepend="AND">apv_id=#ApvId#</isPropertyAvailable>
    <isPropertyAvailable property="StfId" prepend="AND">stf_id=#StfId#</isPropertyAvailable>
    <isPropertyAvailable property="StfName" prepend="AND">stf_name LIKE concat('%', #StfName#, '%')</isPropertyAvailable>
    <isPropertyAvailable property="ApvType" prepend="AND">apv_type=#ApvType#</isPropertyAvailable>
    <isPropertyAvailable property="ApvAlias" prepend="AND">apv_alias LIKE concat('%', #ApvAlias#, '%')</isPropertyAvailable>
</dynamic>
</sql>

<sql id="sql_TApprover_set_cols">
<dynamic prepend="SET">
    <isPropertyAvailable property="StfId" prepend=",">stf_id=#StfId#</isPropertyAvailable>
    <isPropertyAvailable property="StfName" prepend=",">stf_name=#StfName#</isPropertyAvailable>
    <isPropertyAvailable property="ApvType" prepend=",">apv_type=#ApvType#</isPropertyAvailable>
    <isPropertyAvailable property="ApvAlias" prepend=",">apv_alias=#ApvAlias#</isPropertyAvailable>
</dynamic>
</sql>

<select id="SelectTApprover" parameterClass="" resultMap="TApprover.select-tapprover-result">
SELECT *
FROM t_approver
<include refid="sql_TApprover_where_pk"/><!--where-->
</select>

<select id="SelectTApprover_CV" parameterClass="System.Collections.IDictionary" resultMap="TApprover.select-tapprover-result">
SELECT *
FROM t_approver
<include refid="sql_TApprover_where_cv"/><!--where-->
</select>

<insert id="InsertTApprover" parameterClass="TApprover">
<!--pre selectKey place-->
INSERT INTO t_approver(
<dynamic prepend=" ">
    <isPropertyAvailable property="StfId" prepend=",">stf_id</isPropertyAvailable>
    <isPropertyAvailable property="StfName" prepend=",">stf_name</isPropertyAvailable>
    <isPropertyAvailable property="ApvType" prepend=",">apv_type</isPropertyAvailable>
    <isPropertyAvailable property="ApvAlias" prepend=",">apv_alias</isPropertyAvailable>
</dynamic>
)VALUES(
<dynamic prepend=" ">
    <isPropertyAvailable property="StfId" prepend=",">#StfId#</isPropertyAvailable>
    <isPropertyAvailable property="StfName" prepend=",">#StfName#</isPropertyAvailable>
    <isPropertyAvailable property="ApvType" prepend=",">#ApvType#</isPropertyAvailable>
    <isPropertyAvailable property="ApvAlias" prepend=",">#ApvAlias#</isPropertyAvailable>
</dynamic>
)
<selectKey resultClass="int" type="post" property="ApvId" >
SELECT LAST_INSERT_ID()
</selectKey>
</insert>

<update id="UpdateTApprover" parameterClass="System.Collections.IDictionary">
UPDATE t_approver
<include refid="sql_TApprover_set_cols"/><!--set-->
<include refid="sql_TApprover_where_pk"/><!--where-->
</update>

<delete id="DeleteTApprover" parameterClass="">
DELETE FROM t_approver
<include refid="sql_TApprover_where_pk"/><!--where-->
</delete>

<statement id="DeleteTApprover_CV" parameterClass="TApprover">
DELETE FROM t_approver
<include refid="sql_TApprover_where_cv"/><!--where-->
</statement>

<delete id="ClearTApprover">
DELETE FROM t_approver
</delete>
</statements>
</sqlMap>